package com.gxnualbert.proxy.intercept;

import com.gxnualbert.proxy.proxy.HelloWorld;
import com.gxnualbert.proxy.proxy.HelloWorldImpl;

/**
 * @auther gxnualbert
 * @create 2021-05-03-20:28
 */
public class TestInterceptor {
    public static void main(String[] args) {
        testInterceptor();
        testChain();
    }

    public static void testChain() {
        HelloWorld proxy1 = (HelloWorld) InterceptorJdkProxy.bind(
                new HelloWorldImpl(), "com.gxnualbert.proxy.intercept.Interceptor1");
        HelloWorld proxy2 = (HelloWorld) InterceptorJdkProxy.bind(
                proxy1, "com.gxnualbert.proxy.intercept.Interceptor2");
        HelloWorld proxy3 = (HelloWorld) InterceptorJdkProxy.bind(
                proxy2, "com.gxnualbert.proxy.intercept.Interceptor3");
        proxy3.sayHelloWorld();
    }

    public static void testInterceptor() {
        HelloWorld proxy = (HelloWorld) InterceptorJdkProxy.bind(new HelloWorldImpl(),
                "com.gxnualbert.proxy.intercept.MyInterceptor");
        proxy.sayHelloWorld();
    }
}
